package com.controller;

import com.model.Repay;
import com.service.RepayService;
import com.tool.ResponseMessage;
import com.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 编写者：梁颖
 * 编写时间：2019-5-29
 * 类模块描述：查询及相关增删改
 */
@RestController(value = "/Repay")
public class RepayController {
    @Autowired
    private RepayService repayService;
    /*查询数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/getReid")
    public Repay getReid (int reid){return repayService.selectByPrimaryKey(reid);}
    /*查询数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/getPayments")
    public List<Repay> getPayments(){
        System.out.println("调用角色全部类型接口");
        List<Repay> listRepay = repayService.getPayments();
        return listRepay;
    }
    @CrossOrigin
    @RequestMapping(value = "/getAllRe")
    public ResponseMessage getAllRe(){
        System.out.println("调用角色全部信息");
        Map<String,List> map = new HashMap<>();
        map.put("list",repayService.getAllRe());
        return Result.success("200",map);
    }
    /*删除数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/delRe",method = RequestMethod.GET)
    public int delRe(Integer reid){
        return repayService.delRe(reid);
    }
    /*添加数据*/
    @CrossOrigin/*跨越访问*/
    @RequestMapping(value = "/addRe",method = RequestMethod.PUT)
    public int addRe(@RequestBody Repay repaymodel){
        if (repaymodel!=null){

        }
        else
        {}
        return repayService.insertRe(repaymodel);
    }
}
